home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / Tool Chest / Games / Game Sample Code / SpriteWorld 1.0b3 / Examples / Utils / DebugUtils.c next >
Encoding:
Text File  |  1993-06-12  |  1.9 KB  |  98 lines  |  [TEXT/KAHL]

  1. ///--------------------------------------------------------------------------------------
  2. //    DebugUtils.c
  3. //
  4. //    Created:    12/17/91 at 12:35:35 AM
  5. //    By:        Tony Myles
  6. //
  7. //    Copyright: © 1991-93 Tony Myles, All rights reserved worldwide.
  8. //
  9. //    Description:    utility routines used for debugging purposes
  10. ///--------------------------------------------------------------------------------------
  11.  
  12.  
  13. #if THINK_C
  14. #ifndef __BDC__
  15. #include <BDC.h>
  16. #endif
  17. #else
  18. #ifndef __PACKAGES__
  19. #include <Packages.h>
  20. #endif
  21. #endif
  22.  
  23. #ifndef __SEGLOAD__
  24. #include <SegLoad.h>
  25. #endif
  26.  
  27. #ifndef __STRINGUTILS__
  28. #include "StringUtils.h"
  29. #endif
  30.  
  31. #ifndef __DEBUGUTILS__
  32. #include "DebugUtils.h"
  33. #endif
  34.  
  35.  
  36. ///--------------------------------------------------------------------------------------
  37. // DebugNum
  38. ///--------------------------------------------------------------------------------------
  39.  
  40. void DebugNum(
  41.     long bugNum)
  42. {
  43.     Str255 bugNumStr;
  44.  
  45.         // convert the bug number to a string
  46.     NumToString(bugNum, bugNumStr);
  47.  
  48.         // do it
  49.     DebugStr(bugNumStr);
  50. }
  51.  
  52.  
  53. ///--------------------------------------------------------------------------------------
  54. // DebugStrNum
  55. ///--------------------------------------------------------------------------------------
  56.  
  57. void DebugStrNum(
  58.     Str255 bugStr,
  59.     long bugNum)
  60. {
  61.     Str255 tmpStr, bugNumStr;
  62.  
  63.         // copy the bugStr to a local str and append a colon+space to it
  64.     PStrCpy(bugStr, tmpStr);
  65.     PStrCat("\p: ", tmpStr);
  66.  
  67.         // convert the bugNum to a string and append it to the local string
  68.     NumToString(bugNum, bugNumStr);
  69.     PStrCat(bugNumStr, tmpStr);
  70.  
  71.         // do it.
  72.     DebugStr(tmpStr);
  73. }
  74.  
  75.  
  76. ///--------------------------------------------------------------------------------------
  77. // FatalError
  78. ///--------------------------------------------------------------------------------------
  79.  
  80. void FatalError(
  81.     OSErr err,
  82.     Str255 errMsgStr)
  83. {
  84.     if (err != noErr)
  85.     {
  86.         if (errMsgStr == NULL)
  87.         {
  88.             DebugNum((long)err);
  89.         }
  90.         else
  91.         {
  92.             DebugStrNum(errMsgStr, (long)err);
  93.         }
  94.  
  95.         ExitToShell();
  96.     }
  97. }
  98.